package com.example.personnel_oa.controller;

import com.example.comment_oa.dubbo.SysUserDubbo;
import com.example.comment_oa.pojos.SysEmployee;
import com.example.comment_oa.pojos.SysUser;
import com.example.comment_oa.response.AjaxResponse;
import com.example.personnel_oa.mapper.SysEmployeeMapper;
import com.example.personnel_oa.service.SysEmployeeService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("personnelOa")
public class SysEmployeeController {
    @Autowired
    SysEmployeeService employeeService;

    @PostMapping("SysEmployee/selectEmployee")
    public AjaxResponse selectEmployee(){
        List<SysEmployeeMapper> sysEmployeeMappers = employeeService.selectDPE();
        return AjaxResponse.success(sysEmployeeMappers);
    }
    //查询在岗人数
    @PostMapping("SysEmployee/countEmp")
    public AjaxResponse countemp(){
        int countemp = employeeService.countemp();
        return AjaxResponse.success(countemp);
    }
    //查询人事部门的员工//发布人下拉框数据
    @PostMapping("SysEmployee/jobName")
    public AjaxResponse jobName(){
        List<SysEmployee> sysEmployees = employeeService.jobName();
        return AjaxResponse.success(sysEmployees);
    }

    @PostMapping("SysEmployee/empCard/{empCard}")
    public AjaxResponse aaaa(@PathVariable("empCard") String empCard) {
        SysEmployee gonghao = employeeService.gonghao(empCard);
        return AjaxResponse.success(gonghao);
    }
        //员工入职时新增员工
        @PostMapping("SysEmployee/addEmp")
        public AjaxResponse addEmp(@RequestBody SysEmployee employee){
            int i = employeeService.addEmp(employee);
            return AjaxResponse.success(i);
        }

        //入职时添加员工职位中间表，先查出员工id
        @PostMapping("SysEmployee/ID/{empIdcard}")
        public AjaxResponse ID(@PathVariable("empIdcard") String empIdcard){
            SysEmployee id = employeeService.ID(empIdcard);
            return AjaxResponse.success(id);
        }
        //根据岗位名称查询员工
    @GetMapping("SysEmployee/postName/{postsName}")
    public AjaxResponse postName(@PathVariable("postsName")String postsName){
        List<SysEmployee> sysEmployee = employeeService.postName(postsName);
        return AjaxResponse.success(sysEmployee);
    }
    //根据员工id查询信息
    @PostMapping("SysEmployee/selectEmpId/{empId}")
    public AjaxResponse selectEmpId(@PathVariable("empId") int empId){
        SysEmployee id = employeeService.selectEmpId(empId);
        return AjaxResponse.success(id);
    }
    //根据员工id修改试用员工为正式员工
    @PostMapping("SysEmployee/setEmpState/{empId}")
    public AjaxResponse setEmpState(@PathVariable("empId") int empId){
        int id = employeeService.setEmpState(empId);
        return AjaxResponse.success(id);
    }
}



